/**
 * DataTypeConverter.java
 * 2012-3-26 下午08:27:48
 */
package xgenerator.converter;

import xgenerator.constants.SqlDataTypes;
import xgenerator.constants.PhpTypes;
import xgenerator.constants.PropertyTypes;

/**
 * <p>
 * Title:类的中文名
 * </p>
 * <p>
 * Description:具体功能见各方法描述
 * </p>
 * <p>
 * Copyright:Copyright (c) 2012
 * </p>
 * 
 * @author <a href="mailto:lishushan@gmail.com">liss</a>
 * @version 1.0
 */
public class PhpTypeConverter implements PropertyTypeConverter {
	
	public static final PropertyTypes phpTypes = new PhpTypes();
	
	public String convert(String sqlType) {
		String javaType = "";
		
		if(SqlDataTypes.TINYINT_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.byteType();
		} else if(SqlDataTypes.SMALLINT_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.shortType();
		} else if(SqlDataTypes.INTEGER_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.intType();
		} else if(SqlDataTypes.BIGINT_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.longType();
		} else if(SqlDataTypes.FLOAT_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.floatType();
		} else if(SqlDataTypes.DOUBLE_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.doubleType();
		} else if(SqlDataTypes.NUMERIC_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.bigDecimal();
		} else if(SqlDataTypes.CHAR_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.charType();
		} else if(SqlDataTypes.BIT_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.booleanType();
		} else if(SqlDataTypes.VARCHAR_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.string();
		} else if(SqlDataTypes.DATE_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.date();
		} else if(SqlDataTypes.TIME_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.time();
		} else if(SqlDataTypes.TIMESTAMP_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.timestamp();
		} else if(SqlDataTypes.BLOB_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.object();
		} else if(SqlDataTypes.CLOB_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.object();
		} else if(SqlDataTypes.VARBINARY_TYPE.equalsIgnoreCase(sqlType)) {
			javaType = phpTypes.object();
		}
		
		return javaType;
	}
	
}
